package controller;

import entity.hotel_room;
import entity.hotel_tenant;
import service.HotelOrderService;
import serviceImp.HotelOrderServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;


/**
 * Servlet implementation class RegisterController
 */
@WebServlet("/order/RoomInfoController.do")
public class RoomInfoController extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public RoomInfoController() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		request.setCharacterEncoding("utf-8");
		HotelOrderService hotelOrderService = new HotelOrderServiceImp();

		List<hotel_room> roomList = hotelOrderService.selectAllRoom();
		if(roomList==null){
			request.setAttribute("roomTip","房间信息查询失败，请重试");
		}else {
			request.setAttribute("roomList",roomList);
			request.getRequestDispatcher("/order/roomInfo.jsp").forward(request,response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
